Fix examples whose documented output doesn't match Run code - #5718
Merged
kamil-tekiela merged 6 commits intoJul 31, 2026
Conversation
This was referenced Jul 28, 2026
kamil-tekiela
requested changes
Jul 31, 2026
withfragment.xml had no opening <?php, so pressing Run code printed the source instead of running it. getshortname.xml called getName() on the ReflectionConstant::getShortName() page, so it printed the fully qualified name.
saveXML() emits the declaration, but these screens either drop it entirely or drop the encoding the document declares.
These screens use indentation, spacing or a layout the functions never emit: "[0] => " where var_dump() writes "[0]=>" on its own line, hand alignment print_r() does not pad, and spaces where the data holds tabs.
Each of these differs from what the example prints: stale line numbers and offsets, a wrong ordering, a dropped semicolon, a missing line, screens quoting the example's own strings wrongly, and output split across lines that is really printed on one.
date('T') with no timestamp follows daylight saving, so the page showed
PST for half the year and PDT for the other half. Pinning a winter
moment makes the documented output true all year, so the <screen> is
unchanged.
- goto: drop the stack trace, which PHP 8.5 adds and 8.2-8.4 do not, and mark the screen as similar output instead - object to array cast: split the screen into PHP 8.0 and PHP 8.1, the version where the property order changed - createFromString: indent the source by four spaces rather than remove a space from the output - preg_replace: echo a newline so the count stays on its own line
kamil-tekiela
approved these changes
Jul 31, 2026
kamil-tekiela
left a comment
Member
There was a problem hiding this comment.
@jordikroon Is the CI failure something we should be concerned with?
KentarouTakeda
force-pushed
the
fix-screen-mismatch-mechanical
branch
from
July 31, 2026 17:52
8feb8e0 to
1d0c3e2
Compare
Contributor
Author
|
Mine, and it's fixed — green after a rebase onto master. Any branch based before #5682 fails the style check. That's most of the open PRs right now, so they'll go red on their next run until rebased. |
This was referenced Aug 1, 2026
KentarouTakeda
added a commit
to php/doc-ja
that referenced
this pull request
Aug 1, 2026
## 概要 php/doc-en@17c2385178 (php/doc-en#5718) への追従。 変更はすべてコード例の実行結果(`<screen>`)と、実行結果と食い違っていた コード(`<programlisting>`)の修正で、訳文は変更していない。 個々の修正内容とその根拠は php/doc-en#5718 を参照。 ## 対象ファイル(45件) ### language(9件) - types/{array,callable}.xml - control-structures/{switch,foreach,goto,match}.xml - oop5/{basic,lazy-objects,overloading}.xml ### reference(36件) - strings/functions/{explode,rtrim,ltrim,trim,str-word-count,strtok,htmlentities}.xml - array/functions/{array-map,array-fill,array-udiff-assoc,array-unique,array-unshift,natsort}.xml - dom/dom/characterdata/{before,remove,replacewith}.xml - dom/dom/htmldocument/createfromstring.xml - dom/domdocument/append.xml - dom/domdocumentfragment/replacechildren.xml - dom/domelement/{before,getattributenames}.xml - dom/domnode/getlineno.xml - datetime/formats.xml - datetime/functions/{date-default-timezone-get,date-sun-info}.xml - reflection/reflectionclass/{getdefaultproperties,getdoccomment}.xml - reflection/reflectionconstant/getshortname.xml - simplexml/functions/simplexml-load-string.xml - simplexml/simplexmlelement/{children,getDocNamespaces}.xml - libxml/functions/{libxml-get-errors,libxml-set-external-entity-loader}.xml - pcre/functions/preg-replace.xml - uri/uri/rfc3986/uri/withfragment.xml - xmlwriter/xmlwriter/writecdata.xml ## その他 - `strings/functions/ltrim.xml` は EN-Revision の範囲に php/doc-en@46efd98053 (php/doc-en#5726) の `mb_ltrim` → `ltrim` も入るため併せて追従した。 - `strings/functions/strtok.xml` は追従対象の `<screen>` 内に ja 固有の余分な空行があったので除去した。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every example that has a Run code button and declares its output with
&example.outputs;(832 of them) was run and compared against its<screen>.This PR is the subset where the fix needs no judgement: each hunk can be confirmed by clicking Run code on the page.
One commit per group:
<?phpso Run code prints the source instead of running it, one calls getName() on the getShortName() page.var_dump()/print_r()never produce: indentation,[0] =>for[0]=>, hand alignment, spaces where the data holds tabs.date('T')with no timestamp, so the page was right only half the year; the timestamp is now pinned and the screen is unchanged.Pages to reproduce this on
Click any page and press Run code: the output that appears is what this PR puts in the
<screen>. The static<screen>still shown on these pages is the "before" side of the diff, until the manual is rebuilt.Fix two broken examples
Fix the XML declaration in DOM blocks
Use the formatting var_dump() and print_r() actually produce
Fix values that do not match the actual output
Pin the timestamp in the date('T') example